<template>
	<view class="page" v-if="!loadding">
		<!-- #ifdef APP-PLUS -->
		<header-bar></header-bar>
		<!-- #endif -->
		<view class="top-head">
			<view class="head-l">
				<image src="../../../../static/app/jiaotou1.png" @click="gotoPage('/pages/user/orderRecord/detail/detail')" mode=""></image>
			</view>
			<view class="head-title">安排司机</view>
			<view class="head-r" @click="gotoPage('/pages/user/add-driver/add-driver')">+ 添加司机</view>
		</view>

		<view class="list-wrap">
			<!-- 		<block v-for="(item,index) in 5" :key="index">
				<view class="list-item">
					<view class="item-info">
						<view class="info-avatar">
							<image src="../../../static/app/logo.png" mode=""></image>
						</view>
						<view class="info">
							<view class="item-name">
								吴彦祖
							</view>
							<view class="item-tag">
								<text>26岁</text>
								<text>|</text>
								<text>三年驾龄</text>
								<text>|</text>
								<text>C1</text>
								<text>|</text>
								<text>广西桂林</text>
							</view>
						</view>
					</view>
					<view class="item-btn">
						立即沟通
					</view>
				</view>
			</block> -->
			<!-- <view class="list-item">
				<view class="item-info">
					<view class="info-avatar">
						<image src="../../../static/app/logo.png" mode=""></image>
					</view>
					<view class="info">
						<view class="item-name">
							吴彦祖
						</view>
						<view class="item-tag">
							<text>26岁</text>
							<text>|</text>
							<text>三年驾龄</text>
							<text>|</text>
							<text>C1</text>
							<text>|</text>
							<text>广西桂林</text>
						</view>
					</view>
				</view>
				<view class="item-btn">
					立即沟通
				</view>
			</view> -->
			<view class="list-item" v-for="(item,index) of driver" :key="index">
				<view class="item-info">
					<view class="info-avatar">
						<image src="../../../../static/app/logo.png" mode=""></image>
					</view>
					<view class="info">
						<view class="item-name">
							{{item.realname}}
						</view>
						<view class="item-tag">
							<text>26岁</text>
							<text>|</text>
							<text>三年驾龄</text>
							<text>|</text>
							<text>C1</text>
							<text>|</text>
							<text>广西桂林</text>
						</view>
					</view>

				</view>
				<!-- <view class="item-btn">
					立即沟通
				</view> -->
				<view class="info_tick" @click="selectDriver(item)">
					<image v-show="driver_id == item.driver_id" src="../../../../static/tick1.png"></image>
				</view>
				
			</view>
		</view>
		<view class="sure" @click="formData">
			确定
		</view>
		<!-- 没有记录 -->
		<!-- <view class="nullmsg d-c-c p30" v-if="driver.length == 0 && !loadding">
			<text class="iconfont icon-wushuju"></text>
			<text class="cont">亲，暂无相关记录哦</text>
		</view>
		<uni-load-more class="not" v-else :loadingType="loadingType"></uni-load-more> -->
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				loadding: false,
				driver: '',
				driver_id:''
			};
		},
		onLoad() {

		},
		onShow() {
			this.getData();
		},
		computed: {
			/*加载中状态*/
			loadingType() {
				if (this.loadding) {
					return 1;
				} else {
					if (this.driver.length != 0) {
						return 2;
					} else {
						return 0;
					}
				}
			}
		},
		methods: {
			/* 提交 */
			formData(){
				console.log(this.driver_id)
			},
			/* 选择司机 */
			selectDriver(item) {
				this.driver_id = item.driver_id;
			},
			/*获取数据*/
			getData() {
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._get('user.index/my_driver', {}, function(res) {
					console.log(res);
					self.driver = res.data.driver;
					self.loadding = false;
					uni.hideLoading();
				});
			},
			/*跳转页面*/
			gotoPage(path) {
				let self = this;
				if (path.startsWith('/')) {
					uni.navigateTo({
						url: path
					});
				} else {
					self[path]();
				}
			}
		}
	}
</script>

<style lang="scss">
	@import 'arrange.scss';
</style>
